package com.allwees.bs.c.module.sys.repository;

import com.allwees.bs.c.module.base.repository.BaseRepository;
import com.allwees.bs.c.module.sys.entity.SysSequenceEntity;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository
public interface SysSequenceRepository extends BaseRepository<SysSequenceEntity, Long> {

    @Modifying
    @Query("update SysSequenceEntity set current = current +1 where prefix = :prefix ")
    void updateCurrent(@Param("prefix") String prefix);

    @Query("from SysSequenceEntity where prefix = :prefix ")
    SysSequenceEntity selectByPrefix(@Param("prefix") String prefix);
}
